<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>表格</title>

<link rel="stylesheet" type="text/css" href="http://static.365power.cn/static/summer-vue/v0.1.5.38/lib/bootstrap/css/bootstrap.min.css">
<!-- 		<link href="/swift/view/swift/business/css/bootstrap-editable.css" rel="stylesheet" > -->
<!-- 		<link href="/swift/view/swift/business/css/bootstrap-table.min.css" rel="stylesheet" > -->
<!-- 		<script src="/swift/view/swift/business/js/jquery.min.js"></script> -->
<!-- 		<script src="/swift/view/swift/business/js/bootstrap.min.js"></script> -->
<!-- 		<script src="/swift/view/swift/business/js/bootstrap-editable.js"></script> -->
<!-- 		<script src="/swift/view/swift/business/js/bootstrap-table.min.js"></script> -->
<!-- 		<script src="/swift/view/swift/business/js/bootstrap-table-editable.js"></script> -->
<!-- 		<script src="/swift/view/swift/business/js/bootstrap-table-zh-CN.js"></script> -->
<!-- 		<script src="/swift/view/swift/business/js/swift.js"></script> -->
<!-- 		<script type="text/javascript"	src="http://static.365power.cn/static/summer-vue/v0.1.5.38/lib/jquery/jquery.json-2.2.js"></script> -->
		
		
		
<!-- 		<link href="../../css/bootstrap-editable.css" rel="stylesheet" > -->
<!-- 		<link href="../../css/bootstrap-table.min.css" rel="stylesheet" > -->
<!-- 		<script src="../../js/jquery.min.js"></script> -->
<!-- 		<script src="../../js/bootstrap.min.js"></script> -->
<!-- 		<script src="../../js/bootstrap-editable.js"></script> -->
<!-- 		<script src="../../js/bootstrap-table.min.js"></script> -->
<!-- 		<script src="../../js/bootstrap-table-editable.js"></script> -->
<!-- 		<script src="../../js/bootstrap-table-zh-CN.js"></script> -->
<!-- 		<script src="../../js/swift.js"></script> -->
<!-- 		<script type="text/javascript"	src="http://static.365power.cn/static/summer-vue/v0.1.5.38/lib/jquery/jquery.json-2.2.js"></script> -->
<script type="text/javascript" src="/swift/view/swift/js/swift-commons.js"></script>


</head>
<body>
<div class="container-fluid">
	<div id="toolbar" class="btn-group">
	    <a href="#">
	     <button type="button" id="swiftResorceAdd" class="btn btn-default" >
	         <i class="glyphicon glyphicon-plus"></i>添加
	     </button>
	    </a>
	    <a>
	     <button type="button" onclick="del();" id="del" class="btn btn-danger">
	         <i class="glyphicon glyphicon-trash"></i>删除
	     </button>
	    </a>
	    <a>
	    	<button type="button" onclick="kuo();" id="kuo" class="btn btn-default">
	        	<i class="glyphicon glyphicon-trash"></i>扩展功能
	   		</button>
	    </a>
	     <a>
	    	<button type="button" onclick="save();" id="save" class="btn btn-default">
	        	<i class="glyphicon glyphicon-trash"></i>保存
	   		</button>
	    </a>
	</div>
	<table id="swiftResorce"></table>
</div>

<script type="text/javascript">

$('#swiftResorce').bootstrapTable({
    url: '/swift/data/swiftSource?page=10',
// 	url: 'form.json',
    method: 'get',                      //请求方式（*）
	toolbar: '#toolbar',                //工具按钮用哪个容器
	striped: true,                      //是否显示行间隔色
	cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
	pagination: true,                   //是否显示分页（*）
	useCurrentPage:true, 				//
	editable:true,						//开启编辑模式 
	sortable: false,                     //是否启用排序
//		clickToSelect:true,					// 点击 行选中
//		sortOrder: "asc",                   //排序方式
	queryParams: function(){			//传递参数（*）
//			"rows":10
	},			
// 	sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
	pageNumber: 1,                       //初始化加载第一页，默认第一页
	pageSize: 10,                       //每页的记录行数（*）
	undefinedText : '-',
    pageList : [ 5, 10, 20 ],  
    showColumns : true, // 显示隐藏列  
 	showRefresh : true, // 显示刷新按钮  
    columns: [
   	{
   		checkbox:true,
   		formatter:function(value, row, index) {
   		 return {  
                disabled : true,//设置是否可用  
                checked : true,//设置选中 
            };
   		}
   	}, {
        field: 'swiftId',
        title: 'swiftId'
    }, {
        field: 'name',
        title: '名称',
        editable: true,
    }, {
        field: 'actionId',
        title: '动作标识',
        editable: true,
    }, {
        field: 'requsetUrl',
        title: '请求路径',
        sortable: true,
        editable: true,
        editable:{
        	type:"text",
        	title: '请求路径',
        	validate:function (v){
        		if(!v){
        			return "不能为空";
        		}
        	}
        }
    }, {
        field: 'requestType',
        title: '请求类型',
        editable: {
        	   type: 'select',
        	   source: [
        	       {value: 'post', text: 'POST'},
        	       {value: 'get', text: 'GET'},
        	       {value: 'pul', text: 'PUL'},
        	       {value: 'delete', text: 'DELETE'},
        	   ]
        	}
    }, {
        field: 'operationType',
        title: '操作类型',
        editable: {
        	   type: 'select',
        	   source: [
        	       {value: 'insert', text: 'INSERT'},
        	       {value: 'delete', text: 'DELETE'},
        	       {value: 'get', text: 'GET'},
        	   ]
        	}
    }, {
        field: 'actionRule',
        title: '动作限制规则',
        editable: true,
    }, {
        field: 'javaImprove',
        title: 'Java增强',
        editable: true,
    }, {
        field: 'sqlImprove',
        title: 'sql增强',
        editable: true,
    }, {
        field: 'fieldsConfig',
        title: '操作字段选择',
        editable: true,
    }],
    onClickRow: function (row, $element) {
        curRow = row;
    },
});				
// function save() {
// //	    var param = JSON.stringify($("#swiftResorce").bootstrapTable('getData')) ;
//     console.log($("#swiftResorce").bootstrapTable('getSelections'));
//     console.log($("#swiftResorce").bootstrapTable('getAllSelections'));
//     $.ajax({
//         url:'/swift/config/baseinfo/saveSwiftSourceList',
// 		type : 'POST',
// 		cache : false,
// //			data : $.toJSON($("#swiftResorce").bootstrapTable('getData')),
// 		data : $.toJSON($("#swiftResorce").bootstrapTable('getSelections')),
// 		contentType : 'application/json;charset=UTF-8',
//         success:function(msg){
// //             refresh(); //错的
//         }
//     });
// }

// //添加一行
// $(function () {
// 	$('swiftResorceAdd').click(function () {
//     	$("#swiftResorce").bootstrapTable('append',randomData());
// //     	$("#swiftResorce").bootstrapTable('scrollTo', 'bottom');
//     });
// });

// function randomData() {
//     var startId = ~~(Math.random() * 100),
//             rows = [];

//         rows.push({
//         	id: startId +'',
//         	swiftId: (startId),
//         	actionId: 'actionId' + (startId),
//             name: 'name' + (startId),
//             fieldsConfig: 'fieldsConfig' + (startId),
//             requestType: 'requestType' + (startId),
//             requestPath: 'requestPath' + (startId),
//             actionRule: 'actionRule' + (startId),
//             javaImprove: 'javaImprove' + (startId),
//             sqlImprove: 'sqlImprove' + (startId)
//         });
//     return rows;
// }

</script>
</body>
</html>